package com.hilinos.common.util;

import com.hilinos.common.common.ReturnCode;
import com.hilinos.common.entity.RespVo;

import org.springframework.util.ObjectUtils;

public class AssertUtils {

    public static void isNotEmpty(Object obj, ReturnCode returnCode) {
        if (ObjectUtils.isEmpty(obj)) {
            throw new ReturnException(returnCode.resp());
        }
    }

    public static void isNotEmpty(Object obj, String msg) {
        if (ObjectUtils.isEmpty(obj)) {
            throw new ReturnException(msg);
        }
    }

    public static void isNotEmpty(Object obj, RespVo<Object> respVo) {
        if (ObjectUtils.isEmpty(obj)) {
            throw new ReturnException(respVo);
        }
    }

    public static void isNotNull(Object obj, ReturnCode returnCode) {
        if (ObjectUtils.isEmpty(obj)) {
            throw new ReturnException(returnCode.resp());
        }
    }

    public static void isNotNull(Object obj, String msg) {
        if (obj == null) {
            throw new ReturnException(msg);
        }
    }

    public static void isNotNull(Object obj, RespVo<Object> respVo) {
        if (obj == null) {
            throw new ReturnException(respVo);
        }
    }

    public static void isRex(boolean rex, ReturnCode returnCode) {
        if (!rex) {
            throw new ReturnException(returnCode.resp());
        }
    }

    public static void isRex(boolean rex, String msg) {
        if (!rex) {
            throw new ReturnException(msg);
        }
    }

    public static void isRex(boolean rex, RespVo<Object> respVo) {
        if (!rex) {
            throw new ReturnException(respVo);
        }
    }

    public static void throwEx(ReturnCode returnCode) {
        throw new ReturnException(returnCode.resp());
    }

    public static void throwEx(RespVo<Object> respVo) {
        throw new ReturnException(respVo);
    }

    public static void throwEx(String msg) {
        throw new ReturnException(msg);
    }
}
